package com.ledim.bean;

import java.io.Serializable;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.NotNull;
import com.ledim.db.dao.DaoSession;
import com.ledim.db.dao.LedimChoiceCardBeanDao;
import com.ledim.db.dao.LedimPicBeanDao;

/**
 * Created by ccx on 16/7/26.
 * 首页精选card
 */
@Entity(
        //  实体是否激活的标志，激活的实体有更新，删除和刷新的方法
        active = true,
        // 确定数据库中表的名称
        // 表名称默认是实体类的名称
        nameInDb = "CARD")
public class LedimChoiceCardBean implements Serializable {

    @Property(nameInDb = "Id")
    @Id(autoincrement = true)
    private Long id;

    @Property(nameInDb = "photo")
    private long photoId;
    @ToOne(joinProperty = "photoId")
    public LedimPicBean photo; // 图片

    @Property(nameInDb = "type")
    public int type; // 卡片类型
    @Property(nameInDb = "title")
    public String title; // 标题
    @Property(nameInDb = "subtitle")
    public String subtitle; // 子标题

    @Property(nameInDb = "media")
    public String media; // 资源id
    @Property(nameInDb = "submedia")
    public String submedia; // 资源子id
    @Property(nameInDb = "link")
    public String link; // 外链（解析 program: // (id) channel: // (id) 跳转）
    @Property(nameInDb = "playedDuration")
    public long playedDuration;
    @Property(nameInDb = "playedEpisode")
    public String playedEpisode;
    @Property(nameInDb = "time")
    public long time;
    @Property(nameInDb = "nameCn")
    public String nameCn;
    @Transient
    public String url; //
    @Transient
    public LedimSimpleAlbumBean simple_album;

    @Transient
    public boolean isClick;//记录添加放映单中是否被点击

    @Transient
    public ChatRoomBean room;

    @Transient
    public LedimSearchAlbumBean album; // 只在搜索结果输出

    @Transient
    public LedimVideoBean video; // 只在搜索结果相关视频输出
    @Transient
    public int source;//1为正片,2为盗版的
    @Transient
    public String upName;//up主名称

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 913481449)
    public void setPhoto(@NotNull LedimPicBean photo) {
        if (photo == null) {
            throw new DaoException("To-one property 'photoId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.photo = photo;
            photoId = photo.getId();
            photo__resolvedKey = photoId;
        }
    }

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 1398982571)
    public LedimPicBean getPhoto() {
        long __key = this.photoId;
        if (photo__resolvedKey == null || !photo__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            LedimPicBeanDao targetDao = daoSession.getLedimPicBeanDao();
            LedimPicBean photoNew = targetDao.load(__key);
            synchronized (this) {
                photo = photoNew;
                photo__resolvedKey = __key;
            }
        }
        return photo;
    }

    @Generated(hash = 1137958716)
    private transient Long photo__resolvedKey;
    /** Used for active entity operations. */
    @Generated(hash = 1299371547)
    private transient LedimChoiceCardBeanDao myDao;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    public String getNameCn() {
        return this.nameCn;
    }

    public void setNameCn(String nameCn) {
        this.nameCn = nameCn;
    }

    public long getTime() {
        return this.time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getPlayedEpisode() {
        return this.playedEpisode;
    }

    public void setPlayedEpisode(String playedEpisode) {
        this.playedEpisode = playedEpisode;
    }

    public long getPlayedDuration() {
        return this.playedDuration;
    }

    public void setPlayedDuration(long playedDuration) {
        this.playedDuration = playedDuration;
    }

    public String getLink() {
        return this.link;
    }

    public void setLink(String link) {
        this.link = link;
    }

    public String getSubmedia() {
        return this.submedia;
    }

    public void setSubmedia(String submedia) {
        this.submedia = submedia;
    }

    public String getMedia() {
        return this.media;
    }

    public void setMedia(String media) {
        this.media = media;
    }

    public String getSubtitle() {
        return this.subtitle;
    }

    public void setSubtitle(String subtitle) {
        this.subtitle = subtitle;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public int getType() {
        return this.type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public long getPhotoId() {
        return this.photoId;
    }

    public void setPhotoId(long photoId) {
        this.photoId = photoId;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 90568142)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getLedimChoiceCardBeanDao() : null;
    }

    @Generated(hash = 829558176)
    public LedimChoiceCardBean(Long id, long photoId, int type, String title, String subtitle,
                               String media, String submedia, String link, long playedDuration,
                               String playedEpisode, long time, String nameCn) {
        this.id = id;
        this.photoId = photoId;
        this.type = type;
        this.title = title;
        this.subtitle = subtitle;
        this.media = media;
        this.submedia = submedia;
        this.link = link;
        this.playedDuration = playedDuration;
        this.playedEpisode = playedEpisode;
        this.time = time;
        this.nameCn = nameCn;
    }

    @Generated(hash = 1219687097)
    public LedimChoiceCardBean() {
    }
}
